package com.fang.algorithm;

import java.util.Stack;

/**
 * @author fanglingxiao
 * @version 1.0
 * @description TODO
 * @date 2022/8/1 2:39 下午
 **/
public class MyQueue {
    // 入栈
    private Stack<Integer> in = new Stack<>();
    // 出栈
    private Stack<Integer> out = new Stack<>();

    public void push(Integer x) {
        in.push(x);
    }

    public Integer pop() {
        if (out.empty()) {
            while (!in.empty()) {
                Integer pop = in.pop();
                out.push(pop);
            }
        }
        return out.empty() ? null : out.pop();
    }

    public boolean empty() {
        return in.empty() && out.empty();
    }


}
